package com.origin.app.utils.dialog

import android.app.Activity
import com.origin.app.MyApplication

object DialogUtils {
    private var loadingDialog: LoadingDialog? = null
    private fun _showLoadDialog(msg: String = "",mContext:Activity) {
        if (loadingDialog != null && loadingDialog?.isShowing == true) {
            loadingDialog?.setMsg(msg)
            return
        }
        loadingDialog = LoadingDialog(mContext)
        loadingDialog?.showDialog()
        loadingDialog?.setMsg(msg)
    }

    public fun showLoadDialog(msg: String = "加载中...") {
        MyApplication.getInstance().getCurrentActivity()?.apply {
            _showLoadDialog(msg,this);
        }
    }

    public fun closeLoadDialog() {
        MyApplication.getInstance().getCurrentActivity()?.apply {
            loadingDialog?.dismissDialog()
        }
    }
}